import useRequest from '@/utils/request'

const request = useRequest({})
// 查询定时任务调度列表
export function listJob(query: any) {
  return request.get('/schedule/job/list', {
    params: query
  })
}

// 查询定时任务调度详细
export function getJob(jobId: string | number) {
  return request.get('/schedule/job/' + jobId)
}

// 新增定时任务调度
export function addJob(data: any) {
  return request.post('/schedule/job', data)
}

// 修改定时任务调度
export function updateJob(data: any) {
  return request.put('/schedule/job', data)
}

// 删除定时任务调度
export function delJob(jobId: string | number) {
  return request.delete('/schedule/job/' + jobId)
}

// 任务状态修改
export function changeJobStatus(jobId: string | number, status: string | number) {
  const data = {
    jobId,
    status
  }
  return request.put('/schedule/job/changeStatus', data)
}


// 定时任务立即执行一次
export function runJob(jobId: string | number, jobGroup: string | number) {
  const data = {
    jobId,
    jobGroup
  }
  return request.put('/schedule/job/run', data)
}